package com.rzdata.poct.web.controller.business;

import java.util.List;
import java.util.Arrays;

import com.rzdata.poct.common.core.page.TableDataInfo;
import com.rzdata.poct.system.domain.business.bo.PoctMaterialInventorylogsBo;
import com.rzdata.poct.system.domain.business.vo.PoctMaterialInventorylogsVo;
import com.rzdata.poct.system.service.IPoctMaterialInventorylogsService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.rzdata.poct.common.annotation.RepeatSubmit;
import com.rzdata.poct.common.annotation.Log;
import com.rzdata.poct.common.core.controller.BaseController;
import com.rzdata.poct.common.core.domain.AjaxResult;
import com.rzdata.poct.common.core.validate.AddGroup;
import com.rzdata.poct.common.core.validate.EditGroup;
import com.rzdata.poct.common.enums.BusinessType;
import com.rzdata.poct.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2021-09-16
 */
@Validated
@Api(value = "【请填写功能名称】控制器", tags = {"【请填写功能名称】管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/materialInventorylogs")
public class PoctMaterialInventorylogsController extends BaseController {

    private final IPoctMaterialInventorylogsService iPoctMaterialInventorylogsService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation("查询【请填写功能名称】列表")
    @PreAuthorize("@ss.hasPermi('system:materialInventorylogs:list')")
    @PostMapping("/list")
    public TableDataInfo<PoctMaterialInventorylogsVo> list(@RequestBody PoctMaterialInventorylogsBo bo) {
        return iPoctMaterialInventorylogsService.queryPageList(bo);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @ApiOperation("导出【请填写功能名称】列表")
    @PreAuthorize("@ss.hasPermi('system:materialInventorylogs:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(@Validated PoctMaterialInventorylogsBo bo, HttpServletResponse response) {
        List<PoctMaterialInventorylogsVo> list = iPoctMaterialInventorylogsService.queryList(bo);
        ExcelUtil.exportExcel(list, "【请填写功能名称】", PoctMaterialInventorylogsVo.class, response);
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation("获取【请填写功能名称】详细信息")
    @PreAuthorize("@ss.hasPermi('system:materialInventorylogs:query')")
    @GetMapping("/{id}")
    public AjaxResult<PoctMaterialInventorylogsVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iPoctMaterialInventorylogsService.queryById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation("新增【请填写功能名称】")
    @PreAuthorize("@ss.hasPermi('system:materialInventorylogs:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody PoctMaterialInventorylogsBo bo) {
        return toAjax(iPoctMaterialInventorylogsService.insertByBo(bo) ? 1 : 0);
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation("修改【请填写功能名称】")
    @PreAuthorize("@ss.hasPermi('system:materialInventorylogs:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody PoctMaterialInventorylogsBo bo) {
        return toAjax(iPoctMaterialInventorylogsService.updateByBo(bo) ? 1 : 0);
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation("删除【请填写功能名称】")
    @PreAuthorize("@ss.hasPermi('system:materialInventorylogs:remove')")
    @Log(title = "【请填写功能名称】" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iPoctMaterialInventorylogsService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
